Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Aug 12, 2025

Part of WOOMOB-1003

Description

This PR addresses ~50 warnings related to the .onChange usage across Order creation and POS, by moving them to use the new iOS17+ API.

The previous API has been updated and deprecated from forcing us to use 1 parameter, to instead:

  • Use a zero-parameter closure when we don’t care about the value.
  • Use a two-parameter closure (oldValue, newValue) if we need at least one of them.

All changes are a refactor, so no behavior should be changed. Most of times we either don't care about the value and just react to it, or we care about newValue only.

Testing information

Changes affect multiple files, but superficial smoke testing Order Creation and POS flows should be sufficient, ie:

  • In the app, create an order, use the product filters, add a coupon, use the stepper to increase/decrease quantity, expand the totals view, process a payment via TTP, send a receipt. Do this via single selection in mobile, and multi-select in tablet.
  • In POS, setup scanner, go through payment flow, and send a receipt. At some point also move to split view and reduce POS view until is not eligible to use.

Screenshots

N/A


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@dangermattic
Copy link
Collaborator

dangermattic commented Aug 12, 2025

2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is assigned to the milestone 23.2. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@iamgabrielma iamgabrielma added type: task An internally driven task. type: technical debt Represents or solves tech debt of the project. labels Aug 12, 2025
@iamgabrielma iamgabrielma added this to the 23.1 milestone Aug 12, 2025
alwaysVisibleContent()
.trackSize(size: $fixedContentSize)
.onChange(of: fixedContentSize, perform: { [fixedContentSize] _ in
.onChange(of: fixedContentSize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem we need the capture list here: .onChange(of: fixedContentSize) already re-runs the closure every time fixedContentSize changes, so capturing it when created serves no purpose as it will always have the latest value when the closure runs anyway

@iamgabrielma iamgabrielma marked this pull request as ready for review August 12, 2025 03:04
}
.onChange(of: geometry.size.width) {
updateItemImageVisibility(cartListWidth: $0)
.onChange(of: geometry.size.width) { _, newValue in
Copy link
Contributor Author

@iamgabrielma iamgabrielma Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing it implicitly as $0 is no longer something we can do, since we're using the new value inside the closure, we need to be declare it explicitly in .onChange before using it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use $1 instead? This is fine though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ... that's right 🤦

@wpmobilebot wpmobilebot modified the milestones: 23.1, 23.2 Aug 22, 2025
@wpmobilebot
Copy link
Collaborator

Version 23.1 has now entered code-freeze, so the milestone of this PR has been updated to 23.2.

# Conflicts:
#	WooCommerce/Classes/POS/Presentation/Reusable Views/POSModalViewModifier.swift
#	WooCommerce/Classes/POS/Presentation/Reusable Views/POSSheet.swift
@wpmobilebot
Copy link
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16002-1573804
Version23.1
Bundle IDcom.automattic.alpha.woocommerce
Commit1573804
Installation URL6bbdq4pg9lddg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@joshheald joshheald self-assigned this Sep 3, 2025
Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well. Have you stuck to Peacock's areas only? I see there's still 24 of these warnings not fixed here... that's fine but might be worth a heads up to Kiwi.

WooCommerce
woocommerce-ios/WooCommerce/Classes/Authentication/Jetpack Setup/Native Jetpack Setup/JetpackSetupView.swift
woocommerce-ios/WooCommerce/Classes/Authentication/Jetpack Setup/Native Jetpack Setup/JetpackSetupView.swift:291:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift
woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:17:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:35:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:51:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:54:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/AdDestination/BlazeAddParameterView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/AdDestination/BlazeAddParameterView.swift:24:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/AdDestination/BlazeAddParameterView.swift:34:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/CampaignCreation/BlazeCampaignCreationForm.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/CampaignCreation/BlazeCampaignCreationForm.swift:225:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/BlazeCampaignList/BlazeCampaignListView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/BlazeCampaignList/BlazeCampaignListView.swift:158:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Authentication/AccountCreationForm.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Authentication/AccountCreationForm.swift:128:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift:175:46 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift:197:30 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift:238:34 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift:21:18 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Package and Rate Selection/WooAddCustomPackageView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Package and Rate Selection/WooAddCustomPackageView.swift:152:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Package and Rate Selection/WooAddCustomPackageView.swift:155:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingAddresses/WooShippingEditAddressView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingAddresses/WooShippingEditAddressView.swift:88:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingAddresses/WooShippingEditAddressView.swift:265:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/ProductCreationAIStartingInfoView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/ProductCreationAIStartingInfoView.swift:105:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/ProductCreationAIStartingInfoView.swift:109:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/PromptProgressBar/ProductCreationAIPromptProgressBar.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/PromptProgressBar/ProductCreationAIPromptProgressBar.swift:32:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewView.swift:137:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/POS/Presentation/Reusable Views/POSFullScreenCover.swift
woocommerce-ios/WooCommerce/Classes/POS/Presentation/Reusable Views/POSFullScreenCover.swift:80:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

woocommerce-ios/WooCommerce/Classes/POS/Presentation/Reusable Views/POSFullScreenCover.swift:107:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.

@iamgabrielma
Copy link
Contributor Author

Have you stuck to Peacock's areas only? I see there's still 24 of these warnings not fixed here... that's fine but might be worth a heads up to Kiwi.

Yeah, at the moment I loosely split the work in batches around features/files by each team in WOOMOB-1003 so it's easier for testing. Depending on priorities and if they are unable to get to it, then we can do another pass. I'll ping with a reminder to the leads again in any case, as it seems the issue stalls if it doesn't go through proper triage.

@iamgabrielma iamgabrielma merged commit 58c6ebd into trunk Sep 4, 2025
15 checks passed
@iamgabrielma iamgabrielma deleted the task/wcios17-updates-to-onchange-v1 branch September 4, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task. type: technical debt Represents or solves tech debt of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants